require 'time'
require 'pp'
require 'enumerable.rb'

class Movie
  include Comparable
  include Enumerable
  attr_reader :name
  attr_reader :showtime
  def initialize(name,showtime)
    @name = name
    if showtime.is_a?(Time)
        @showtime = showtime
    elsif showtime.is_a?(String)
        @showtime = Time.parse(showtime)
    else
        raise ArgumentError, "Invalid time input!"
	end
  end
  def name_and_showtime
    rtn = name.to_s + ": "
    time = showtime.strftime("%I:%M %p")
    if showtime > Time.now
      rtn += "next show at #{time}"
    else
      rtn += "already started at #{time}"
    end
    return rtn
  end
  def <=>(x)
    return showtime<=>x.showtime
  end
end

movies = []
movies << Movie.new("Orphan", Time.parse("1:00 pm"))
movies << Movie.new("Orphan", Time.parse("4:05 pm"))
movies << Movie.new("Orphan", Time.parse("7:00 pm"))
movies << Movie.new("GI Joe", Time.parse("1:05 pm"))
movies << Movie.new("GI Joe", Time.parse("4:30 pm"))
movies << Movie.new("GI Joe", Time.parse("6:50 pm"))
movies << Movie.new("Rocky Horror", Time.parse("12:00 am"))
movies << Movie.new("District 9", Time.parse("11:00 am"))
movies << Movie.new("District 9", Time.parse("3:00 pm"))
movies << Movie.new("Inglourious Basterds", "2:35 pm")
movies << Movie.new("Inglourious Basterds", "1:00 pm")
#movies << Movie.new("Inglourious Basterds", 100)